home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 983 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: doc.ic.ac.uk!not-for-mail
  2. From: rwmj@doc.ic.ac.uk (Richard Jones)
  3. Newsgroups: comp.lang.c
  4. Subject: Override a cpp macro?
  5. Date: 10 Jan 1996 18:05:47 -0000
  6. Organization: Dept. of Computing, Imperial College, University of London, UK.
  7. Distribution: world
  8. Message-ID: <4d0v5r$6fs@oak78.doc.ic.ac.uk>
  9. NNTP-Posting-Host: oak78.doc.ic.ac.uk
  10.  
  11. I'm trying to redefine a cpp macro, but using the old definition. I've got
  12. a macro defined:
  13.  
  14.     #define m1(a,b) /* some hidden definition of m1 */
  15.  
  16. and in another file, I want to redefine m1 in terms of the old (unknown)
  17. definition. Two obvious ways would be:
  18.  
  19.     #define old_m1(a,b) m1(a,b)
  20.     #undef m1
  21.     #define m1(a,b) (old_m1(a,b)+1)
  22.  
  23. or:
  24.  
  25.     #define new_m1(a,b) (m1(a,b)+1)
  26.     #undef m1
  27.     #define m1(a,b) new_m1(a,b)
  28.  
  29. But neither works as expected. I've tried variations using the macro:
  30.  
  31.     #define expand(a) a
  32.  
  33. which according to the Gnu info page for (Gnu) cpp should expand the
  34. argument first. However, no known combination works.
  35.  
  36. What's the way to do this? Surely this is an obvious thing to want to do,
  37. so there must be some simple point I'm missing?
  38.  
  39. Rich.
  40. -- 
  41. "The real tight interface is between the book and the reader - the world of
  42. the book is plugged right into your brain, never mind the [virtual reality]
  43. bodysuit"
  44. -- from The Age of Missing Information, by Bill McKibben.
  45.